<template>
  <div class="toDoPage">
    <a-spin :spinning="spinning">
      <div class="todoSearch" style="position:absolute;top:0px;right:15px;">
        <span class="tabItemTitle" v-if="selectTabKey == '2'">
                  <a-button type="primary" @click="showApplyComplete(1)">{{$t('todoPage.applicationCompleted')}}</a-button>
                </span>
        <div class="selectStatus" v-if="selectTabKey == '1'">
          <div class="targetStatus">{{$t('todoPage.status.processStatus')}}</div>
          <a-select style="width: 80%" :default-value="dropdownKey" v-model="dropdownKey"
                    @change="workDropDown">
            <a-select-option :key="index" :value="item.key" v-for="(item, index) in targetStatusList_process">
              {{ item.display }}
            </a-select-option>
          </a-select>
        </div>
        <div class="selectStatus" v-if="selectTabKey == '2'">
          <div class="targetStatus">{{$t('todoPage.status.taskStatus')}}</div>
          <a-select style="width: 100%" :default-value="dropdownKey" v-model="dropdownKey"
                    @change="projectDropDown(selectTabKey,dropdownKey)">
            <a-select-option :key="index" :value="item.key" v-for="(item, index) in targetStatusList_task">
              {{ item.display }}
            </a-select-option>
          </a-select>
        </div> 
        <div class="selectStatus" v-if="selectTabKey == '3'">
          <div class="targetStatus">{{$t('todoPage.status.taskStatus')}}</div>
          <a-select style="width: 100%" :default-value="dropdownKey" v-model="dropdownKey"
                    @change="projectDropDown(selectTabKey,dropdownKey)">
            <a-select-option :key="index" :value="item.key" v-for="(item, index) in targetStatusList_taskNo">
              {{ item.display }}
            </a-select-option>
          </a-select>
        </div>
        <div class="inputBox">
          <global-search ref="global_search" :searchTableData="lastTableData"
                          @onSearch="onSearchCallBack"></global-search>
        </div>
      </div>
      <a-row :gutter="16">
        <a-col :span="24">
          <div class="tabBox">
            <!-- <a-tabs v-model="selectTabKey" @change="tabCallBack(selectTabKey,dropdownKey)">
              <a-tab-pane v-for="item in tabCategoryList" :key="item.id">
                <span class="tab-title" slot="tab">
                  {{item.name}}
                  <div class="taskNum" v-if="item.id == '1' && parseInt(toDoProcessNum) > 0">{{ toDoProcessNum }}</div>
                  <div class="taskNum" v-if="item.id == '2' && parseInt(outTask) > 0">{{ outTask }}</div>
                  <div class="taskNum" v-if="item.id == '3' && parseInt(toReviewedTask) > 0">{{ toReviewedTask }}</div>
                </span>
              </a-tab-pane>
            </a-tabs>-->
            <tabs :defaultTagId="selectTabKey" :tabPaneData="tabCategoryList" :fieldData="fieldData" :custom="false" @change="tabCallBack($event,dropdownKey)"></tabs>
          </div>
          <div class="tableItem">
            <a-row>
              <a-col :span="6">
                <!-- <span class="tabItemTitle" v-if="selectTabKey == '1'">流程列表</span> -->
                <!-- <span class="tabItemTitle" v-else-if="selectTabKey == '2'">
                  <a-button type="primary" @click="showApplyComplete(1)">申请完成</a-button>
                </span> -->
                <!-- <span class="tabItemTitle" v-else-if="selectTabKey == '3'">审核任务列表</span> -->
                <div>
                  <!--动态显示抽屉（单条/多条）抽屉打开不能再次刷新方法 在父组件添加v-if-->
                  <component :is="applyCom" :drawerVisible_p="drawVisible" v-if="drawVisible" :oid="oid"
                            :assignmentOid="assignmentOid"
                            :taskName="taskName"
                            :dataStatus="dataStatus"
                            :isHaveDelive="isHaveDelive"
                            :action="taskAction"
                            :dataObj="carryTaskValue"
                            @closeDraw="closeApplyComplete"></component>
                </div>
              </a-col>
              <!-- <a-col :span="18" class="todoSearch">
                <div class="selectStatus" v-if="selectTabKey == '1'">
                  <div class="targetStatus">流程状态 :</div>
                  <a-select style="width: 100%" :default-value="dropdownKey" v-model="dropdownKey"
                            @change="workDropDown">
                    <a-select-option :key="index" :value="item.key" v-for="(item, index) in targetStatusList_process">
                      {{ item.display }}
                    </a-select-option>
                  </a-select>
                </div>
                <div class="selectStatus" v-if="selectTabKey == '2'">
                  <div class="targetStatus">任务状态 :</div>
                  <a-select style="width: 100%" :default-value="dropdownKey" v-model="dropdownKey"
                            @change="projectDropDown(selectTabKey,dropdownKey)">
                    <a-select-option :key="index" :value="item.key" v-for="(item, index) in targetStatusList_task">
                      {{ item.display }}
                    </a-select-option>
                  </a-select>
                </div>
                <div class="selectStatus" v-if="selectTabKey == '3'">
                  <div class="targetStatus">任务状态 :</div>
                  <a-select style="width: 100%" :default-value="dropdownKey" v-model="dropdownKey"
                            @change="projectDropDown(selectTabKey,dropdownKey)">
                    <a-select-option :key="index" :value="item.key" v-for="(item, index) in targetStatusList_taskNo">
                      {{ item.display }}
                    </a-select-option>
                  </a-select>
                </div>
                <div class="inputBox">
                  <global-search ref="global_search" :searchTableData="lastTableData"
                                @onSearch="onSearchCallBack"></global-search>
                </div>
              </a-col> -->
            </a-row>
            <a-row style="margin: 0 20px 0px 20px;">
              <!-- @routerPageThem="routerPageThem" -->
              <common-table-todo 
                :columns="toDoColumns"
                :tableData="tableData"
                :selectType="'checkbox'"
                :data-row-key="tableKey"
                :filterData="filterDataTable"
                @filterTable="filterTable"
                @routerPage="routerPage"
                @routerActionPage="routerActionPage"
                @routerDeliverable="routerDeliverable"
                @routerToProject="routerToProject"
                :is-rows-select-visible="isRowsSelectVisible"
                :loadVisible="false"
                :this-table-name="thisTableName"
                :this-table-header-data="thisTableHeaderData"
                :this-table-header-data-middel="thisTableHeaderDataMiddel"
                @paginationFun="paginationFun"
                ref="commonTable"
              ></common-table-todo>
            </a-row>
          </div>
        </a-col>
      </a-row>
    </a-spin>
  </div>
</template>
<script>
import globalSearch from "@/components/common/globalSearch"
import commonTableTodo from "@/components/common/commonTableTodo";
import tabs from "@/components/tabs/tabs"
import applyCompleteOnce from "@views/plmHomePage/toDoPage/applyCompleteOnce";
import applyCompleteMore from "@views/plmHomePage/toDoPage/applyCompleteMore";
import {
  getWorkItemAttrs,
  getWorkItemList,
  getProjectTaskAttrs,
  getProjectTaskList,
  getProjectTaskAttrsForApproval,
  getProjectTaskListForApproval,
  demandManage
} from '@/api/todoPage'
import carryTask from "@views/plmHomePage/toDoPage/carryTask";
import carryTaskNoDo from "@views/plmHomePage/toDoPage/carryTaskNoDo";
import examineTask from "@views/plmHomePage/toDoPage/examineTask";
import deliverableList from "@views/plmHomePage/toDoPage/deliverableList";
import {getCustomizeHeaders} from '@/api/middleGround'
import _ from 'lodash'
import {getProjectCaches} from '@/api/projectManage'
import { closeSingleTabs } from '@/api/common'
import { todopage } from '@/views/plmHomePage/projectPlanningDoc/mixins/todoPage'
import { columnsDemand } from '../columnsDemand'
let userinfo = JSON.parse(sessionStorage.getItem('userInfo'))
import { getQisUrl } from'@/api/qualityInfoSystem.js'
export default {
  name: "toDoPage",
  mixins:[ todopage ],
  props: {
    tabCategoryList: {
      type: Array,
      defualt: () => []
    },
    workSpaceItem: {
      type: Object,
      defualt: () => ({})
    }
  },
  data() {
    return {
      spinning: false,
      fieldData: {name: 'name', enName: 'tagEnName', id: 'id', num: 'num'},
      selectTabKey: "1",//选中的tab的key
      isRowsSelectVisible: false,//表格复选框是否显示
      toDoProcessNum: 0,//待办流程数量
      outTask: 0,//执行任务
      toReviewedTask: 0,//待审核任务
      demandManage: 0,
      targetStatusList_process: [
        {key: "ALL", display: "全部"},
        {key: "NOT_COMPLETED", display: "进行中"},
        {key: "COMPLETED", display: "已完成"},
      ],//流程状态下拉框
      targetStatusList_task: [
        {key: "ALL", display: "全部"},
        {key: "WORKING", display: "执行中"},
        {key: "COMPLETED", display: "已完成"}
      ],//执行任务状态下拉框
      targetStatusList_taskNo: [
        {key: "ALL", display: "全部"},
        {key: "PENDINGAPPROVAL", display: "待审核"},
        {key: "COMPLETED", display: "已完成"}
      ],//审核任务状态下拉框
      dropdownKey: 'NOT_COMPLETED',//下拉框选中的数据
      toDoColumns: [],//页面显示的表头数据
      tableKey: '',//表格的key
      tableData: [],//页面显示的表格数据
      lastTableData: [],//页面显示的表格数据（最后保存）
      loadVisible: false,
      drawVisible: false, //抽屉
      applyCom: "applyCompleteOnce", //抽屉名称
      searchInput: '',//搜索框内容
      thisTableName: '执行任务',//当前表格名称
      thisTableHeaderData: [],//当前表格所有表头数据
      thisTableHeaderDataMiddel: [],//当前表格存在中台的表头数据
      oid: '',//任务id
      assignmentOid: '',//表格中的某个id
      taskName: '产品定义评审-test',//任务名称
      dataStatus: '已完成',//数据状态
      isHaveDelive: '否',//是否有交付物
      healthStatusImgObj: {
        'green': require('@/assets/manageMain/green.svg'),
        'yellow': require('@/assets/manageMain/yellow.svg'),
        'red': require('@/assets/manageMain/red.svg'),
        'gray': require('@/assets/manageMain/gray.svg'),
      },// 健康状态图片对象
      taskAction: '执行任务',//点击表格动作
      filterData: {}, //筛选条件
      filterDataTable: {}, //筛选条件
      carryTaskValue: {}, //执行任务传参
      columnsDemand,
      //分页参数
      pageCount: 5, // 每页显示条数
      startIndex: 0, // 起始页第一条
    };
  },
  components: {
    globalSearch,
    tabs,
    // commonTable,
    commonTableTodo,
    applyCompleteOnce,
    applyCompleteMore,
    carryTask,
    carryTaskNoDo,
    examineTask,
    deliverableList
  },
  computed: {
    loadNum() {
      return this.$store.state.loadTable.num
    },//vuex数据，表头设置点击“确定”，刷新数据
    commitCount() {
      return this.$store.state.commitApply
    },//vuex数据，申请完成点击“确定”，刷新数据
  },
  watch: {
    // tabCategoryList: {
    //   handler: function (arr) {
    //     // if (arr[0] && arr[0].id !== this.selectTabKey) {
    //     //   this.selectTabKey = arr[0].id
    //     //   this.tabCallBack(arr[0].id, this.dropdownKey)// tab切换
    //     // }
    //     // if (arr.length >= 3) {
    //     //   this.initData();
    //     // }
    //   },
    //   deep: true,
    //   immediate: true
    // },
    $route() {
      this.initData();
    },
    //监听抽屉打开/关闭
    drawVisible(val) {
    },
    commitCount(val) {
      if (this.selectTabKey == '2') {
        this.tabCallBack('2', this.dropdownKey)// tab切换
      } else if (this.selectTabKey == '3') {
        this.tabCallBack('3', this.dropdownKey)// tab切换
      } else if (this.selectTabKey == '4') {
        this.tabCallBack('4', this.dropdownKey)// tab切换
      }
      this.getTableToDoNum()//刷新待办数量
    },
    //监听表头设置
    loadNum(value) {
      // console.log('vuex的数据------------------', this.$store.state.loadTable)
      // console.log('tabKey+下拉框------------------', this.dropdownKey)
      if (this.$store.state.loadTable.tableName === '待办流程') {
        this.tabCallBack('1', this.dropdownKey)// tab切换
      } else if (this.$store.state.loadTable.tableName === '执行任务') {
        this.tabCallBack('2', this.dropdownKey)// tab切换
      } else if (this.$store.state.loadTable.tableName === '审核任务') {
        this.tabCallBack('3', this.dropdownKey)// tab切换
      }else if (this.$store.state.loadTable.tableName === '需求管理') {
        this.tabCallBack('4', this.dropdownKey)// tab切换
      }
    },
    selectTabKey(val) {
      this.filterDataTable = this.filterData[this.selectTabKey] || {}
    }
  },
  mounted() {
    let filterData = JSON.parse(sessionStorage.getItem('filterData') || '{}').toDoPage
    if (filterData) {
      this.filterData = filterData
      this.filterDataTable = this.filterData[this.selectTabKey] || {}
    }
    this.tabCallBack(this.selectTabKey, this.dropdownKey)// tab切换
  },
  methods: {
    // 分页
    paginationFun(pageValue, info) {
      if (this.selectTabKey === "1") {
        this.pageCount = pageValue.pageSize
        this.startIndex = pageValue.pageSize * (pageValue.current - 1 )
        this.getTableData("1", this.dropdownKey);
      }
    },
    // 初始化数据
    initData() {
      // this.tabCallBack('1', this.dropdownKey)// tab切换
      this.getTableToDoNum()//获取表格待操作的数量
    },
    // 流程下拉框搜素
    workDropDown(value) {
      this.dropdownKey = value
      this.getTableData('1', value)
    },
    // 任务下拉框搜素
    projectDropDown(tabKey, value) {
      this.dropdownKey = value
      this.getTableData(tabKey, value)
    },
    filterTable(filterData) {
      this.filterData[this.selectTabKey] = filterData
      let filterDataSession = JSON.parse(sessionStorage.getItem('filterData') || '{}')
      filterDataSession.toDoPage = this.filterData
      sessionStorage.setItem('filterData', JSON.stringify(filterDataSession))
    },
    // tab切换
    tabCallBack(tabKey, status) {
      this.spinning = true
      this.selectTabKey = tabKey
      //获取表头
      if (tabKey == '1') {
        this.dropdownKey = 'NOT_COMPLETED'
        status = this.dropdownKey
        this.thisTableName = '待办流程'//当前表格名称
        this.getMiddleHeaderData('1', '待办流程')
        this.getTableData('1', status)//获取表格数据
        this.tableKey = "workItemOid"
        /*this.thisTableHeaderDataSort = ["操作", "进程名称", "流程名称", "状态", "创建时间", "角色", "完成者", "完成日期", "状况", "工作负责人",
          "备注", "最后期限", "流程类型", "项目名称", "创建者"]//当前表格全部表头排序的数据(左侧暂不用排序)*/
      } else if (tabKey == '2') {
        this.dropdownKey = 'WORKING'
        status = this.dropdownKey
        this.thisTableName = '执行任务'//当前表格名称
        this.getMiddleHeaderData('2', '执行任务')
        this.getTableData('2', status)//获取表格数据
        this.tableKey = "activityOid"
        /*this.thisTableHeaderDataSort = ["操作", "任务名称", "是否有交付物", "交付物", "项目名称", "状态", "任务发布时间", "健康状态", "审核人", "审批意见",
          "执行人", "交付物状态", "目标完成时间", "目标工期", "实际完成时间","所属计划"]//当前表格全部表头排序的数据(左侧暂不用排序)*/
      } else if (tabKey == '3') {
        this.dropdownKey = 'PENDINGAPPROVAL'
        status = this.dropdownKey
        this.thisTableName = '审核任务'//当前表格名称
        this.getMiddleHeaderData('3', '审核任务')
        this.getTableData('3', status)//获取表格数据
        this.tableKey = "activityOid"
        /*this.thisTableHeaderDataSort = ["操作", "任务名称", "是否有交付物", "交付物", "项目名称", "状态", "任务发布时间", "健康状态", "审核人", "审批意见",
          "执行人", "交付物状态", "目标完成时间", "目标工期", "实际完成时间","所属计划"]//当前表格全部表头排序的数据(左侧暂不用排序)*/
      }else if (tabKey == '4') {
        this.dropdownKey = 'PENDINGAPPROVAL'
        status = this.dropdownKey
        this.thisTableName = '需求管理'//当前表格名称
        // this.getMiddleHeaderData('4', '需求管理')
        this.getDemandManage()//获取表格数据
        this.tableKey = "activityOid"
        /*this.thisTableHeaderDataSort = ["操作", "任务名称", "是否有交付物", "交付物", "项目名称", "状态", "任务发布时间", "健康状态", "审核人", "审批意见",
          "执行人", "交付物状态", "目标完成时间", "目标工期", "实际完成时间","所属计划"]//当前表格全部表头排序的数据(左侧暂不用排序)*/
      }
    },
    // 获取需求管理列表
    getDemandManage() {
      this.toDoColumns = this.columnsDemand
      let params = {
        page: 0,  // 页码
        size: 1000,   // 每页大小
        fdSubject: "",// ":"支持待办任务名称模糊查询",  -- 非必填
        // userName: userinfo.loginName ,// ":"用户域账号",   --
        fdMsgType: "", // ":"1 待办，2 已办，3 已删除" , --  非必填 为空时 查全部
        // signData: "域账号+秘钥  然后再MD5"   -- 必填
        userName: userinfo.loginName
      }
      this.loadVisible = true
      demandManage(params).then(res=> {
        if (res && res.status === 200) {
          if (res.data && res.data.body.content) {
            if (res.data.body.content.length > 0) {
              this.tableData = _.orderBy(res.data.body.content, ['fdCreateTime'], ['desc'])//按照创建时间降序排序
              this.lastTableData = _.clone(_.orderBy(res.data.body.content, ['fdCreateTime'], ['desc']))
              this.loadVisible = false
              // console.log('执行任务表格数据---', this.tableData)
              setTimeout(() => {
                this.$refs.global_search.searchValue = ''
                this.$refs.global_search.onSearch()
              }, 20)
              this.spinning = false
            } else {
              this.tableData = []
              this.loadVisible = false
              this.spinning = false
            }
          } else {
            this.tableData = []
            this.loadVisible = false
            this.$message.error(res.data.msg)
            this.spinning = false
          }
        } else {
          this.tableData = []
          this.loadVisible = false
          this.$message.error('接口失败')
        }
      })
    },
    // 1.获取执行任务表头表头------>分两步：1.先获取中台的自定义设置表头，返回有数据则显示中台数据；2.若中台无返回数据，则获取所有表头
    getMiddleHeaderData(tabKey, tableName) {
      //获取中台接口
      let middleParms = {
        "tableName": tableName,
        "userId": userinfo.loginName
      }
      getCustomizeHeaders(middleParms).then(res => {
        // console.log(res)
        if (res.status === 200 && res.data) {
          let middleHeadersDataOld = res.data.labelList
          if (middleHeadersDataOld.length > 0) {
            this.thisTableHeaderDataMiddel = middleHeadersDataOld.split(',')
            // console.log(this.thisTableHeaderDataMiddel)
            this.getColumns(tabKey, this.thisTableHeaderDataMiddel)
          } else {
            // this.thisTableHeaderDataMiddel = []
            this.getColumns(tabKey, [])
          }
        } else {
          this.$message.error('获取表头失败')
          this.thisTableHeaderDataMiddel = []
        }
      })
    },
    getColumns(tabKey, headersData) {
      this.toDoColumns = []
      // key=1为待办流程；key=2为执行任务；key=3为待审核任务
      if (tabKey == '1') {
        getWorkItemAttrs().then(res => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                this.thisTableHeaderData = _.clone(res.data.data);//所有表格头数据
                let columnData = res.data.data;
                columnData.forEach((item, index) => {
                  // 项目名称
                  if (item.name === "activity.name" || item.name === "operation") {
                    item.scopedSlots = {
                      customRender: "name",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "process.container") {
                    item.scopedSlots = {
                      customRender: "projectName",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "workItem.theme") {
                    item.scopedSlots = {
                      customRender: "theme",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else {
                    item.scopedSlots = {
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                      customRender: "customRender"
                    };
                  }
                });
                // console.log('待办流程表头数据---前', columnData)
                let arrNew = []
                if (headersData.length > 0) {
                  arrNew = _.filter(columnData, function (o) {
                    return headersData.indexOf(o.displayName) !== -1;
                  })
                  arrNew = _.sortBy(arrNew, (rec) => {
                    return headersData.indexOf(rec.displayName)
                  })
                } else {
                  arrNew = columnData
                }
                // console.log('待办流程表头数据---后', arrNew)
                //添加设置表头按钮
                arrNew.push({
                  dataIndex: "setting",
                  fixed: "right",
                  width: 40,
                  slots: {title: "customTitle"}
                });
                //在第一列添加√（当状态为已完成）
                // arrNew.unshift({
                //   dataIndex: "workComplete",
                //   width: 30,
                //   scopedSlots: {customRender: "workComplete"}
                // })
                /*//获取“交付物”下标，并在后方加上小眼睛图标
                let deliverIndex = _.findIndex(arrNew, (rec => {
                  return rec.displayName === '交付物'
                }))
                if (deliverIndex > -1) {
                  arrNew.splice(deliverIndex + 1, 0, {
                    dataIndex: "taskDeliver",
                    width: 20,
                    scopedSlots: {customRender: "taskDeliver"}
                  })
                }*/
                this.toDoColumns = arrNew;
                // console.log('待办流程表头数据---', this.toDoColumns)
              } else {
                this.toDoColumns = []
              }
            } else {
              this.toDoColumns = []
              this.$message.error(res.data.message)
            }
          } else {
            this.$message.error('接口失败')
            this.toDoColumns = []
          }
        })
      } else if (tabKey == '2') {
        // console.log('获取中台表头:', headersData)
        getProjectTaskAttrs().then(res => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                this.thisTableHeaderData = _.clone(res.data.data);//所有表格头数据
                let columnData = res.data.data;
                columnData.forEach((item, index) => {
                  // 项目名称
                  if (item.name === "activity.name" ) {
                    item.scopedSlots = {
                      customRender: "name",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "activity.operation") {
                    item.scopedSlots = {
                      customRender: "action",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "deliverable.name") {
                    item.scopedSlots = {
                      customRender: "taskDeliverable",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "project.name") {
                    item.scopedSlots = {
                      customRender: "projectName",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "assignment.healthStatusType") {
                    item.scopedSlots = {
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                      customRender: "img",
                    };
                  } else {
                    item.scopedSlots = {
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                      customRender: "customRender"
                    };
                  }
                });
                // console.log('执行任务表头数据---前', columnData)
                let arrNew = []
                if (headersData.length > 0) {
                  arrNew = _.filter(columnData, function (o) {
                    return headersData.indexOf(o.displayName) !== -1;
                  })
                  arrNew = _.sortBy(arrNew, (rec) => {
                    return headersData.indexOf(rec.displayName)
                  })
                } else {
                  arrNew = columnData
                }
                // console.log('执行任务表头数据---后', arrNew)
                //添加设置表头按钮
                arrNew.push({
                  dataIndex: "setting",
                  fixed: "right",
                  width: 40,
                  slots: {title: "customTitle"}
                });
                //在第一列添加√（当状态为已完成）
                // arrNew.unshift({
                //   dataIndex: "taskComplete",
                //   width: 30,
                //   scopedSlots: {customRender: "taskComplete"}
                // })
                /*//获取“交付物”下标，并在后方加上小眼睛图标
              let deliverIndex = _.findIndex(arrNew, (rec => {
                return rec.displayName === '交付物'
              }))
              if (deliverIndex > -1) {
                arrNew.splice(deliverIndex + 1, 0, {
                  dataIndex: "taskDeliver",
                  width: 20,
                  scopedSlots: {customRender: "taskDeliver"}
                })
              }*/
                // console.log('交付物的下标：', deliverIndex)
                this.toDoColumns = arrNew;
                // console.log('执行任务表头数据---', this.toDoColumns)
              } else {
                this.toDoColumns = []
              }
            } else {
              this.toDoColumns = []
              this.$message.error(res.data.message)
            }
          } else {
            this.$message.error('接口失败')
            this.toDoColumns = []
          }
        })
      } else if (tabKey == '3') {
        getProjectTaskAttrsForApproval().then(res => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                this.thisTableHeaderData = _.clone(res.data.data);//所有表格头数据
                let columnData = res.data.data;
                columnData.forEach((item, index) => {
                  // 项目名称
                  if (item.name === "activity.name" || item.name === "deliverable.status") {
                    item.scopedSlots = {
                      customRender: "name",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "activity.operation") {
                    item.scopedSlots = {
                      customRender: "action",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "deliverable.name") {
                    item.scopedSlots = {
                      customRender: "taskDeliverable",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "project.name") {
                    item.scopedSlots = {
                      customRender: "projectName",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "assignment.healthStatusType") {
                    item.scopedSlots = {
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                      customRender: "img",
                    };
                  } else {
                    item.scopedSlots = {
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                      customRender: "customRender"
                    };
                  }
                });
                // console.log('审核任务表头数据---前', columnData)
                let arrNew = []
                if (headersData.length > 0) {
                  arrNew = _.filter(columnData, function (o) {
                    return headersData.indexOf(o.displayName) !== -1;
                  })
                  arrNew = _.sortBy(arrNew, (rec) => {
                    return headersData.indexOf(rec.displayName)
                  })
                } else {
                  arrNew = columnData
                }
                // console.log('审核任务表头数据---后', arrNew)
                //添加设置表头按钮
                arrNew.push({
                  dataIndex: "setting",
                  fixed: "right",
                  width: 40,
                  slots: {title: "customTitle"}
                });
                //在第一列添加√（当状态为已完成）
                arrNew.unshift({
                  dataIndex: "taskComplete",
                  width: 30,
                  scopedSlots: {customRender: "taskComplete"}
                })
                /*//获取“交付物”下标，并在后方加上小眼睛图标
                let deliverIndex = _.findIndex(arrNew, (rec => {
                  return rec.displayName === '交付物'
                }))
                if (deliverIndex > -1) {
                  arrNew.splice(deliverIndex + 1, 0, {
                    dataIndex: "taskDeliver",
                    width: 20,
                    scopedSlots: {customRender: "taskDeliver"}
                  })
                }*/
                this.toDoColumns = arrNew;
                // console.log('审核任务表头数据---', this.toDoColumns)
              } else {
                this.toDoColumns = []
              }
            } else {
              this.toDoColumns = []
              this.$message.error(res.data.message)
            }
          } else {
            this.$message.error('接口失败')
            this.toDoColumns = []
          }
        })
      }
    },
    // 获取表格数据
    getTableData(tabKey, status) {
      this.$refs.commonTable.pagination.total = 0
      this.loadVisible = true
      // console.log(status, tabKey)
      this.tableData = []
      // key=1为待办流程；key=2为执行任务；key=3为待审核任务
      if (tabKey == '1') {
        this.isRowsSelectVisible = false
        let parms = {
          // "userId": "wcadmin",
          "status": status,
          "pagingSearch": true,
          "count": this.pageCount,
          "startIndex": this.startIndex
        }
        //OR:wt.workflow.work.WfAssignedActivity:1862217
        getWorkItemList(parms).then(res => {
          /*let aaa =  _.filter(res.data.data,(it)=>{
            return _.includes(it['workItemOid'],'WfAssignedActivity:1862217')
          })
          console.log('res-------->',aaa)*/
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                this.tableData = _.orderBy(res.data.data, ['workItem.thePersistInfo.createStamp'], ['desc'])//按照创建时间降序排序
                this.lastTableData = _.clone(_.orderBy(res.data.data, ['workItem.thePersistInfo.createStamp'], ['desc']))
                this.loadVisible = false
                // console.log('执行任务表格数据---', this.tableData)
                setTimeout(() => {
                  this.$refs.global_search.searchValue = ''
                  this.$refs.global_search.onSearch()
                }, 20)
                this.spinning = false
              } else {
                this.tableData = []
                this.loadVisible = false
                 this.spinning = false
              }
              this.$refs.commonTable.pagination.total = res.data.size
            } else {
              this.tableData = []
              this.loadVisible = false
              this.$message.error(res.data.message)
              this.spinning = false
              this.$refs.commonTable.pagination.total = 0
            }
          } else {
            this.tableData = []
            this.loadVisible = false
            this.$message.error('接口失败')
            this.spinning = false
            this.$refs.commonTable.pagination.total = 0
          }
        })
      } else if (tabKey == '2') {
        this.isRowsSelectVisible = true
        let parms = {
          // "userId": "wcadmin",
          "status": status
        }
        getProjectTaskList(parms).then(res => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                res.data.data.map(item => {
                  if (item['assignment.healthStatusType'] === '灰') {
                    item.healthstatusimg = this.healthStatusImgObj.gray
                  } else if (item['assignment.healthStatusType'] === '绿') {
                    item.healthstatusimg = this.healthStatusImgObj.green
                  } else if (item['assignment.healthStatusType'] === '黄') {
                    item.healthstatusimg = this.healthStatusImgObj.yellow
                  } else if (item['assignment.healthStatusType'] === '红') {
                    item.healthstatusimg = this.healthStatusImgObj.red
                  }
                })
                // this.tableData = res.data.data
                this.tableData = _.orderBy(res.data.data, ['assignment.openTaskDate'], ['desc'])//按照创建时间降序排序
                this.lastTableData = _.clone(_.orderBy(res.data.data, ['assignment.openTaskDate'], ['desc']))
                this.loadVisible = false
                // console.log('执行任务表格数据---', this.tableData)
                setTimeout(() => {
                  this.$refs.global_search.searchValue = ''
                  this.$refs.global_search.onSearch()
                }, 20)
                 this.spinning = false
              } else {
                this.tableData = []
                this.loadVisible = false
                 this.spinning = false
              }
            } else {
              this.tableData = []
              this.loadVisible = false
              this.$message.error(res.data.message)
               this.spinning = false
            }
          } else {
            this.tableData = []
            this.loadVisible = false
            this.$message.error('接口失败')
            
          }
        })
      } else if (tabKey == '3') {
        this.isRowsSelectVisible = false
        let parms = {
          // "userId": "wcadmin",
          "status": status
        }
        getProjectTaskListForApproval(parms).then(res => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                res.data.data.map(item => {
                  if (item['assignment.healthStatusType'] === '灰') {
                    item.healthstatusimg = this.healthStatusImgObj.gray
                  } else if (item['assignment.healthStatusType'] === '绿') {
                    item.healthstatusimg = this.healthStatusImgObj.green
                  } else if (item['assignment.healthStatusType'] === '黄') {
                    item.healthstatusimg = this.healthStatusImgObj.yellow
                  } else if (item['assignment.healthStatusType'] === '红') {
                    item.healthstatusimg = this.healthStatusImgObj.red
                  }
                })
                this.tableData = _.orderBy(res.data.data, ['assignment.openTaskDate'], ['desc'])//按照创建时间降序排序
                this.lastTableData = _.clone(_.orderBy(res.data.data, ['assignment.openTaskDate'], ['desc']))
                this.loadVisible = false
                // console.log('执行任务表格数据---', this.tableData)
                setTimeout(() => {
                  this.$refs.global_search.searchValue = ''
                  this.$refs.global_search.onSearch()
                }, 20)
                 this.spinning = false
              } else {
                this.tableData = []
                this.loadVisible = false
                 this.spinning = false
              }
            } else {
              this.tableData = []
              this.loadVisible = false
              this.$message.error(res.data.message)
               this.spinning = false
            }
          } else {
            this.tableData = []
            this.loadVisible = false
            this.$message.error('接口失败')
             this.spinning = false
          }
        })
      }
    },
    goRouterQis(oid) {
      getQisUrl({oid}).then(res => {
        if(res.data.message) {
          window.open(unescape(res.data.message))
        } else {
          this.$message.warning('地址不存在')
        }
      })
    },
    //获取表格待办的数量
    getTableToDoNum() {
      //待办流程数量
      let parms_1 = {
        "status": 'NOT_COMPLETED',
        "pagingSearch": true,
        "count": this.pageCount,
        "startIndex": this.startIndex
      }
      getWorkItemList(parms_1).then(res => {
        if (res && res.status === 200) {
          if (res.data && res.data.data && res.data.success) {
            if (res.data.data.length > 0) {
              // this.toDoProcessNum = res.data.data.length;
              this.toDoProcessNum = res.data.size
              this.$set(this.tabCategoryList[0], 'num', this.toDoProcessNum)
            } else {
              this.toDoProcessNum = 0
            }
          } else {
            this.toDoProcessNum = 0
            this.$message.error(res.data.message)
          }
        } else {
          this.toDoProcessNum = 0
          this.$message.error('接口失败')
        }
        this.$store.commit('setTodoProcessNum', this.toDoProcessNum)
      })
      //待执行任务数量
      let parms_2 = {
        // "userId": "wcadmin",
        "status": 'WORKING'
      }
      getProjectTaskList(parms_2).then(res => {
        if (res && res.status === 200) {
          if (res.data && res.data.data && res.data.success) {
            if (res.data.data.length > 0) {
              this.outTask = res.data.data.length
              this.$set(this.tabCategoryList[1], 'num', this.outTask)
            } else {
              this.outTask = 0
            }
          } else {
            this.outTask = 0
            this.$message.error(res.data.message)
          }
        } else {
          this.outTask = 0
          this.$message.error('接口失败')
        }
        this.$store.commit('setOutTask', this.outTask)
      })
      //待审核任务数量
      let parms_3 = {
        // "userId": "wcadmin",
        "status": 'PENDINGAPPROVAL'
      }
      getProjectTaskListForApproval(parms_3).then(res => {
        if (res && res.status === 200) {
          if (res.data && res.data.data && res.data.success) {
            if (res.data.data.length > 0) {
              this.toReviewedTask = res.data.data.length
              this.$set(this.tabCategoryList[2], 'num', this.toReviewedTask)
            } else {
              this.toReviewedTask = 0
            }
          } else {
            this.toReviewedTask = 0
          }
        } else {
          this.$message.error('接口失败')
        }
        this.$store.commit('setToReviewedTask', this.toReviewedTask)
      })
      // 需求管理任务数据
      let params = {
        page: 0,  // 页码
        size: 1000,   // 每页大小
        fdSubject: "",// ":"支持待办任务名称模糊查询",  -- 非必填
        // userName: userinfo.loginName ,// ":"用户域账号",   --
        fdMsgType: "", // ":"1 待办，2 已办，3 已删除" , --  非必填 为空时 查全部
        // signData: "域账号+秘钥  然后再MD5"   -- 必填
        userName: userinfo.loginName
      }
      demandManage(params).then(res=> {
        if (res && res.status === 200) {
          if (res.data && res.data.body.content) {
            if (res.data.body.content.length > 0) {
              this.demandManage = res.data.body.content.length
              this.$set(this.tabCategoryList[3], 'num', this.demandManage)
            } else {
              this.demandManage = 0
            }
          } else {
            this.demandManage = 0
          }
        } else {
          this.$message.error('接口失败')
        }
        this.$store.commit('setDemandManage', this.demandManage)
      })
    },
    // 第一个tab，点击“操作”跳转 || 点击第二个tab中任务名称显示的抽屉
    routerPage(val) {
      const projectObj = {
        projectName: val['process.container'],
        projectType:  val['process.project.type']
      }
      sessionStorage.setItem("ProjectObj", JSON.stringify(projectObj))
      sessionStorage.setItem("fromRouteName", "todoPageList")
      /* session值项目名称--头部  开始  */
      if (val.pboOid && val.pboOid.indexOf("Planning") == -1) {
        let str = "";
        if (this.selectTabKey === "1") {
          str = val["process.container.oid"];
        } else {
          str = val.projectOid;
        }
        if(str){    //仿真委托书不属于项目里面的，所有委托书的流程里没有项目的oid
          sessionStorage.setItem("oid", str && str.substring(str.lastIndexOf(":") + 1));
        }
      }
      /* session值项目名称--头部  结束   */
      if (this.selectTabKey == '1') {
        /*// this.tableKey = "workItemOid"
        this.oid = val.activityOid
        window.open(val['operation.url'])*/
        if (val['pbo.localizedType'].indexOf('文档') > -1 || 
          // val['pbo.localizedType'].indexOf('PM') > -1 ||
          val["pboOid"].indexOf("WTDocument") != -1) {
          //待办流程点击操作跳转至流程交付物页面（操作界面）
          let fileSingleTableItem_s = {
            oid: val['workItemOid'],//流程oid
            singleOid:val['pboOid'],  //文档Oid
            workItemName: val['operation'],//流程节点名称
            state: val['pbo.state'],//流程状态
            // pboOid: val['pboOid'],//交付物id
            workItemState: val['workItem.status']//交付物状况
          }
          sessionStorage.setItem("fileSingleTableItem", JSON.stringify(fileSingleTableItem_s))
          this.$store.commit('SET_PROJECT_FILE_TITLE', '')
          closeSingleTabs()
          this.$router.push({
            path: '/single/fileSingle/examineProject',
          })
        } else if (val['pboOid'].indexOf('ProjectKnotItemBook') != -1) { /**验收表流程入口 */
          let fileSingleTableItem_s = {
            oid: val['workItemOid'],//流程oid
            workItemName: val['operation'],//流程节点名称
            state: val['pbo.state'],//流程状态 
            pboOid: val['pboOid'],//验收表id
            workItemState: val['workItem.status'],//验收表状况
            processName: val['workItem.theme']
          }
          sessionStorage.setItem("acceptListData", JSON.stringify(fileSingleTableItem_s))
          let typeObj = {
            type: 'process',
             acceptId: val['pboOid']
          }
          sessionStorage.setItem('addAcceptListObj', JSON.stringify(typeObj))
          sessionStorage.setItem('processAcceptInfo', JSON.stringify(typeObj))
          // sessionStorage.setItem('acceptProcessInfo', JSON.stringify(fileSingleTableItem_s))
          closeSingleTabs()
          this.$router.push({
            path: '/single/projectAcceptList/porjectAcceptProcess',
          })
        } else if (val['process.name'].startsWith("QIS")) {
          closeSingleTabs()
          this.goRouterQis(val.workItemOid)
        } else if ( val.pboOid.indexOf("sany.pmgt.tdm.model") != -1) {
          this.toBookRouterTDM(val)
        } else if (val["pboOid"].indexOf("ProjectIssue") != -1) {
          sessionStorage.setItem('questionItem', JSON.stringify(val))
          if(val.operation === "修改"){
              this.$router.push({
                path: '/single/questionSingle/editQuestion',
              })
          }else{
              this.$router.push({
                path: '/single/questionSingle/examineQuestion',
              })
          }
        } else if (val["pboOid"].indexOf("ProjectRisk") != -1) {
          sessionStorage.setItem('riskItem', JSON.stringify(val))
          if(val.operation === "修改"){
              this.$router.push({
                path: '/single/riskSingle/examineRiskBack',
              })
          }else{
              this.$router.push({
                path: '/single/riskSingle/examineRisk',
              })
          }
        } else if (val["pboOid"].indexOf("RMTask") != -1) { //需求RM（需求任务单流程）
          sessionStorage.setItem('demandItem', JSON.stringify(val))
          closeSingleTabs()
          if(val.operation === "需求关联" || val.operation === "移除需求关联的项目" || val.operation === "更改需求任务单"){
              this.$router.push({
                // path: '/single/demandSingle/examineDemand',
                path: '/toDoPage/examineDemand',
              })
          }
        } else if (val["pboOid"].indexOf("PPMSubPlan") != -1) { //需求关联（子规划流程）
          sessionStorage.setItem('ppmdemandItem', JSON.stringify(val))
          closeSingleTabs()
          if(val.operation === "需求关联" || val.operation === "移除需求关联的项目"){
              this.$router.push({
                // path: '/single/demandSingle/childPlan',
                path: '/toDoPage/childPlan',
              })
          }
        } else if (val.pboOid.indexOf("Planning") != -1) {
          this.toBookRouter(val)
        } else if ( val.pboOid.indexOf("EntrustBook") != -1) {
          if (val['toPlm'] === "true") {
            this.$message.warn('非项目仿真委托需去PLM系统处理')
            return false
          }
          console.log('仿真委托书流程信息',val);
          this.toBookRouterSDM(val);      //SDM仿真委托书
        } else if (val["pbo.localizedType"].indexOf('评审') > -1 || val["pboOid"].indexOf("PIReview") != -1){
          sessionStorage.setItem('reviewId',val.pboOid)
          sessionStorage.setItem("workItemOid",val.workItemOid)
          sessionStorage.setItem("techProcessName",val['process.name'])
          sessionStorage.setItem("craftOperation",val.operation) 
          closeSingleTabs()
          if(val.operation === "审阅"){
            this.$router.push({
              path: '/single/reviewSingle/selfCheck',
            })
          }else if(val.operation === "修改完善"){
            this.$router.push({
              path: '/single/reviewSingle/modifyPerfect',
            })
          }else if(val.operation === "修改"){
            this.$router.push({
              path: '/single/reviewSingle/rejectModify',
            })
          }else{
            sessionStorage.setItem("operation", val.operation)
            this.$router.push({
              path: '/single/reviewSingle/PMOReview',    
              // query: {
              //   operation: val.operation
              // }     
            })
          }
        } else if (val['process.name'].indexOf('SNProjectCloseWF') != -1) {
            //项目关闭 SNProjectCloseWF    process.name
            sessionStorage.setItem("closedData", JSON.stringify(val));
            this.$router.push({
              path: "/single/projectMain/closeExamine",
            });
        } else if (val["pbo.localizedType"].indexOf("项目变更") > -1 || val["pboOid"].indexOf("PIProjectChangeRequest") != -1 ) { //项目变更
          sessionStorage.setItem("changeAlterationData", JSON.stringify(val));
          if(val.operation === "修改"){
            let strs = val['process.container.oid'];
            sessionStorage.setItem("oid", strs.substring(strs.lastIndexOf(":") + 1));
            this.$router.push({
              path: "/single/projectAlteration/editAlteration",
            });
          }else{
            this.$router.push({
              path: "/single/projectAlteration/changeAlteration",
            });
          }
        } else {
          // this.$message.info('暂不支持该流程操作！')
          window.open(val['process.name.url'])
        }
      } else if (this.selectTabKey == '2') {
        // this.tableKey = "activityOid"
        this.oid = val.activityOid
        this.assignmentOid = val.assignmentOid
        this.taskName = val['activity.name']
        this.dataStatus = val['assignment.plannableStatus']
        this.isHaveDelive = val['hasPIDeliverable']
        this.taskAction = ''
        // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
        this.showApplyComplete(5)//执行任务
      } else if (this.selectTabKey == '3') {
        // this.tableKey = "activityOid"
        this.oid = val.activityOid
        this.assignmentOid = val.assignmentOid
        this.taskName = val['activity.name']
        this.dataStatus = val['assignment.plannableStatus']
        this.isHaveDelive = val['hasPIDeliverable']
        this.taskAction = ''
        // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
        this.showApplyComplete(4)//审核任务
      } else if (this.selectTabKey == '4') {
        // console.log(val)
        window.open(val.fdDetailUrl)
      }
    },
    //  点击第二个和第三个tab切换“操作”跳转
    routerActionPage(val) {
      sessionStorage.setItem("fromRouteName", "todoPageList")
      /* session值项目名称--头部  开始  */
      if (val.pboOid && val.pboOid.indexOf("Planning") == -1) {
        let str = "";
        if (this.selectTabKey === "1") {
          str = val["process.container.oid"];
        } else {
          str = val.projectOid;
        }
        sessionStorage.setItem("oid", str && str.substring(str.lastIndexOf(":") + 1));
      }
      /* session值项目名称--头部  结束   */
      if (this.selectTabKey == "1") {
        if (
          val["pbo.localizedType"].indexOf("文档") > -1 ||
          val["pbo.localizedType"].indexOf("PM") > -1 ||
          val["pboOid"].indexOf("WTDocument") != -1
        ) {
          //待办流程点击操作跳转至流程交付物页面（操作界面）
          let fileSingleTableItem_s = {
            oid: val["workItemOid"], //流程oid
            workItemName: val["operation"], //流程节点名称
            state: val["pbo.state"], //流程状态
            // pboOid: val['pboOid'],//交付物id
            workItemState: val['workItem.status']//交付物状况
          }
          sessionStorage.setItem("fileSingleTableItem", JSON.stringify(fileSingleTableItem_s))
          this.$store.commit('SET_PROJECT_FILE_TITLE', '')
          closeSingleTabs()
          this.$router.push({
            path: "/single/fileSingle/examineProject",
          });
        } else {
          this.$message.info("暂不支持该流程操作！");
        }
      } else if (this.selectTabKey == "2") {
        this.carryTaskValue = val
        sessionStorage.setItem('projectOid',JSON.stringify(val.projectOid))
        // this.tableKey = "activityOid"
        this.oid = val.activityOid;
        this.assignmentOid = val.assignmentOid;
        this.taskName = val["activity.name"];
        this.dataStatus = val["assignment.plannableStatus"];
        this.isHaveDelive = val["hasPIDeliverable"];
        this.taskAction = "执行任务";
        // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
        let str = val.projectOid
        sessionStorage.setItem('oid', str.substring(str.lastIndexOf(":") + 1));
        this.showApplyComplete(3); //执行任务
      } else if (this.selectTabKey == "3") {
        // this.tableKey = "activityOid"
        this.oid = val.activityOid;
        this.assignmentOid = val.assignmentOid;
        this.taskName = val["activity.name"];
        this.dataStatus = val["assignment.plannableStatus"];
        this.isHaveDelive = val["hasPIDeliverable"];
        this.taskAction = "审核任务";
        // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
        this.showApplyComplete(4); //审核任务
      }
      // // console.log('点击操作跳转',this.selectTabKey);
      // if (this.selectTabKey == '1') {
      //   // this.tableKey = "workItemOid"
      //   this.oid = val.activityOid
      //   window.open(val['operation.url'])
      // } else if (this.selectTabKey == '2') {
      //   // this.tableKey = "activityOid"
      //   this.carryTaskValue = val
      //   this.oid = val.activityOid
      //   this.assignmentOid = val.assignmentOid
      //   this.taskName = val['activity.name']
      //   this.dataStatus = val['assignment.plannableStatus']
      //   this.isHaveDelive = val['hasPIDeliverable']
      //   this.taskAction = '执行任务'
      //   // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
      //   let str = val.projectOid
      //   sessionStorage.setItem('oid', str.substring(str.lastIndexOf(":") + 1));
      //   this.showApplyComplete(3)//执行任务
      // } else if (this.selectTabKey == '3') {
      //   // this.tableKey = "activityOid"
      //   this.oid = val.activityOid
      //   this.assignmentOid = val.assignmentOid
      //   this.taskName = val['activity.name']
      //   this.dataStatus = val['assignment.plannableStatus']
      //   this.isHaveDelive = val['hasPIDeliverable']
      //   this.taskAction = '审核任务'
      //   // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据 
      //   this.showApplyComplete(4)//审核任务
      // }
    },
    //点击交付物跳转
    routerDeliverable(val) {
      sessionStorage.setItem("fromRouteName", "todoPageList")
      if (val.pboOid && val.pboOid.indexOf("Planning") == -1) {
        let str = "";
        if (this.selectTabKey === "1") {
          str = val["process.container.oid"];
        } else {
          str = val.projectOid;
        }
        sessionStorage.setItem("oid", str && str.substring(str.lastIndexOf(":") + 1));
      }
      //  console.log('点击交付物跳转', val)
      this.oid = val.activityOid
      this.showApplyComplete(2)//交付物列表
    },
    //点击流程名称跳转--文件详情
    // routerPageThem(val) {
    //   /* session值项目名称--头部  开始  */
    //   let str = ''
    //   if (this.selectTabKey === '1') {
    //     str = val['process.container.oid']
    //   } else {
    //     str = val.projectOid
    //   }
    //   sessionStorage.setItem('oid', str.substring(str.lastIndexOf(":") + 1));
    //   /* session值项目名称--头部  结束   */
    //   if (val['pbo.localizedType'].indexOf('文档') > -1 || val['pbo.localizedType'].indexOf('PM') > -1) {
    //     /*// console.log('点击主题跳转', val)
    //     this.oid = val.activityOid
    //     window.open(val['workItem.theme.url'])*/
    //     //待办流程点击操作跳转至流程交付物页面
    //     let fileSingleTableItem_s = {
    //       oid: val['pboOid'],//流程oid
    //       workItemName: val['operation'],//流程节点名称
    //       state: val['pbo.state'],//流程状态
    //       // pboOid: val['pboOid'],//交付物id
    //       workItemState: val['workItem.status'],//交付物状况
    //     }
    //     sessionStorage.setItem("fileSingleTableItem", JSON.stringify(fileSingleTableItem_s))
    //     this.$store.commit('SET_PROJECT_FILE_TITLE', '')
    //     closeSingleTabs()
    //     this.$router.push({
    //       path: '/single/fileSingle/examineProject',
    //     })
    //   } else {
    //     this.$message.info('当前流程不是文档类型，暂不支持详情查看！')
    //   }
    // },
    //每个tab点击项目跳转--单项目首页
    routerToProject(val) {
      sessionStorage.setItem("fromRouteName", "portalMain")
      /* session值项目名称--头部  开始  */
     if(val.pboOid){
      if(val.pboOid.indexOf("PPMSubPlan") > -1 || val.pboOid.indexOf("RMTask") > -1){
            this.$message.error("该流程没有关联的项目")
      }
     }
      let str = ''
      if (val.pboOid && val.pboOid.indexOf("Planning") == -1) {
        if (this.selectTabKey === "1") {
          str = val["process.container.oid"];
        } else {
          str = val.projectOid;
        }
        sessionStorage.setItem("oid", str && str.substring(str.lastIndexOf(":") + 1));
      } else {
        str = val.projectOid;
        sessionStorage.setItem("oid", str && str.substring(str.lastIndexOf(":") + 1));
      }
      /* session值项目名称--头部  结束   */
      //获取项目信息
      let arr = []
      arr.push(sessionStorage.getItem("oid"))
      getProjectCaches(arr).then(res => {
        if (res.status === 200) {
          if (res.data && res.data.length > 0) {
            const projectObj = {
              projectName: res.data[0].projectName,
              projectType:  res.data[0].projectType
            }
            sessionStorage.setItem("ProjectObj", JSON.stringify(projectObj))
            if (res.data[0].projectType === '软件开发项目') {
              sessionStorage.setItem("projectSmallType", res.data[0].projectSmallType)
            }
            closeSingleTabs()
            this.$router.push({
              path: '/single/projectMain',
              query: {
                oid: str.substring(str.lastIndexOf(":") + 1)
              }
            })
          }
        } else {
          this.$message.error('获取数据失败')
        }
      }).catch(error => {
        this.$message.error('获取数据接口异常')
      })
    },
    //展开抽屉
    showApplyComplete(num) {
      switch (num) {
        case 1:
          if (this.$store.state.selectedTableData.length === 1) {
            this.applyCom = "applyCompleteOnce";
            this.assignmentOid = this.$store.state.selectedTableData[0].assignmentOid
          } else if (this.$store.state.selectedTableData.length > 1) {
            this.applyCom = "applyCompleteMore";
          } else {
            this.$message.error('请最少选择一项任务！')
            this.applyCom = ''
          }
          break;
        case 2:
          this.applyCom = "deliverableList";
          break;
        case 3:
          this.applyCom = "carryTask";
          break;
        case 4:
          this.applyCom = "examineTask";
          break;
         case 5:
          this.applyCom = "carryTaskNoDo";
          break;
      }
      this.drawVisible = true;
      // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
      // console.log('vuex的表格数据：', this.$store.state.selectedTableData)
    },
    //关闭抽屉
    closeApplyComplete() {
      this.drawVisible = false;
    },
    // 全局搜索
    onSearchCallBack(tableVal, searchValue) {
      if (!searchValue) {
        // 当传过来的数据为空，并且输入条件为空时，重新调用
        // this.getTableDataParams(t his.defaultTagId)
        this.tableData = _.clone(this.lastTableData)
      } else {
        this.tableData = tableVal
      }
    },
  },
};
</script>
<style scoped lang="less">
.selectStatus {
  width: 320px;
  display: flex;
  justify-content: flex-start;
  margin-right: 20px;
  .targetStatus {
    color: #666;
    font-size: 14px;
    width: 130px;
    line-height: 32px;
  }
  .targetConclusion {
    width: 120px;
  }
  /deep/ .ant-select-dropdown-menu-item-selected {
    color: #2f54eb;
  }
}
.todoSearch {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-right: 12px;
  position: relative;
  z-index: 1;
}
.toDoPage {
  // height: 100%;
  // min-height: 800px;
  background-color: #fff;
  text-align: center;
  // padding: 200px 0 0 0;
  border-radius: 4px;
  //margin-top: -24px;
  h1 {
    font-size: 48px;
  }
  .tabBox {
    padding: 2px 12px 0px 12px;
    /deep/ .ant-tabs-nav {
      display: flex;
    }
    /deep/ .ant-tabs-nav .ant-tabs-tab {
      padding: 5px 9px;
    }
    .tab-title {
      width: 100%;
      height: 30px;
      //background-color: green;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .taskNum {
      min-width: 18px;
      height: 18px;
      border-radius: 100px;
      background-color: #f5222d;
      margin: -15px 0px 0px 5px;
      padding: 0px 3px 0px 3px;
      line-height: 18px;
      color: #ffffff;
      font-size: 12px;
    }
    /*.taskNumZero {
      min-width: 18px;
      height: 18px;
      border-radius: 100px;
      background-color: #386bd7;
      margin: -15px 0px 0px 5px;
      padding: 0px 3px 0px 3px;
      line-height: 18px;
      color: #ffffff;
      font-size: 12px;
    }*/
  }
  .tableItem {
    margin-top: 0px;
    // /deep/ .ant-table-body {
    //   min-height: calc(100vh - 383px);
    // }
    /deep/ .ant-table-placeholder {
      // min-height: calc(100vh - 383px);
      margin-top: -420px;
      border: none;
    }
    .tabItemTitle {
      float: left;
      padding-left: 20px;
      font-weight: 600;
      color: black;
      font-size: 18px;
    }
    .selectStatus {
      width: 320px;
      display: flex;
      justify-content: flex-start;
      margin-right: 20px;
      .targetStatus {
        color: #666;
        font-size: 14px;
        width: 130px;
        line-height: 32px;
      }
      .targetConclusion {
        width: 120px;
      }
      /deep/ .ant-select-dropdown-menu-item-selected {
        color: #2f54eb;
      }
    }
    .todoSearch {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      padding-right: 12px;
    }
  }
}
</style>
<style scoped>
</style>